package com.cy.pj.sys.web.exception;

import com.cy.pj.sys.web.pojo.JsonResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice//此注解注释的类是全局处理类
public class GlobalExpectionHandler {
    public static final Logger log = LoggerFactory.getLogger(GlobalExpectionHandler.class);

    @ExceptionHandler(IllegalAccessException.class)
    public JsonResult doHandkeRuntimeException(IllegalAccessException e){
        e.printStackTrace();
        log.error("exception msg is {}",e.getMessage());
        return new JsonResult(e);

    }

    @ExceptionHandler(RuntimeException.class)
    public JsonResult doHandkeRuntimeException(RuntimeException e){
        e.printStackTrace();
        log.error("exception msg is {}",e.getMessage());
        return new JsonResult(e);

    }
}
